package server.utils;

import game.Player;
import game.client.Table;
import game.server.ServerTable;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;



public class Utils {
	/**
	 * Date format.
	 */
	static final String DATE_FORMAT_NOW = "dd-MM-yyyy HH:mm:ss";
	
	/**
	 * Method for getting current date and time.
	 * @return Current date and time.
	 */
	public static String now() {
	    Calendar cal = Calendar.getInstance();
	    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
	    return sdf.format(cal.getTime());

	}
	/**
	 * Converts ServerTable into Table.
	 * @param table ServerTable to convert.
	 * @return Converted table.
	 */
	public static Table convertServerTable(ServerTable table) {
		Table output = new Table();
		output.setBetOnTable(table.getBetOnTable());
		for (Player p : table.getPlayers()) {
			output.addOpponent(p);
		}
		return output;
	}
}
